package tg.webclient.beans.tslx;

import java.io.PrintStream;
import java.rmi.RemoteException;
import java.util.Vector;
import psdi.app.workorder.WPMaterial;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
import psdi.webclient.system.beans.DataBean;
import psdi.webclient.system.beans.LookupBean;
import psdi.webclient.system.controller.AppInstance;
import psdi.webclient.system.controller.SessionContext;

/***
 * 
 * @author pzx
 *
 */
public class WtNumLookupbean extends LookupBean {
	
	public int REFRESHLIST() throws MXException, RemoteException {
		MboSetRemote tsSet = getMboSetRemote();
		MboRemote opOwner = tsSet.getOwner();
		String jpSetWhere = opOwner.getList("wtnum").getRelationship();
		tsSet.setWhere(jpSetWhere);
		tsSet.reset();
		refreshTable();
		structureChangedEvent(this);
		fireDataChangedEvent(this);
		this.sessionContext.queueRefreshEvent();
		getMboSetRemote();
		this.app.getAppBean().fireDataChangedEvent(this.app.getAppBean());
		return 1;
	}

	public void copyPrToMr(MboSetRemote sourcePRLineSet, String s)
			throws MXException, RemoteException {
		String wonum = s;
		if (sourcePRLineSet.isEmpty()){
			return;
		}
		Vector prLineSize = sourcePRLineSet.getSelection();
		if (prLineSize.size() == 0){
			return;
		}
		System.out.println("size= " + prLineSize.size());
		sourcePRLineSet.setOrderBy("prnum, prlinenum");
		sourcePRLineSet.resetWithSelection();
		MboSetRemote invlineset = this.app.getDataBean("1383622047714").getParent().getMbo().getMboSet("SHOWPLANMATERIAL");
		for (int i = 0; i < prLineSize.size(); i++) {
			MboRemote sourcePRLine = (MboRemote) prLineSize.elementAt(i);
			sourcePRLine.setValue("REFWO", wonum, 11L);
			WPMaterial balline = (WPMaterial) invlineset.add();
			balline.setValue("WONUM", wonum, 2L);
		
		}
	}
}
